package com.situ.mall.admin.interceptor;

import com.situ.mall.admin.entity.Administrator;
import com.situ.mall.admin.util.RequestUtil;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * ClassName: LoginInterceptor
 * Package: com.situ.springboottest.interceptor
 * Description:
 *
 * @Author Darling_达
 * @Create 2023-03-15 16:39
 * @Version 1.0
 */

// 登录拦截器
public class LoginInterceptor implements HandlerInterceptor {


    @Override
    public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
        Administrator administrator = RequestUtil.getCurrent();
        if (administrator == null) {
            resp.sendRedirect("/login");
        }
        return administrator != null;
    }


}
